package com.my.study.net;

import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;

/**
 * @author: yidujun
 * @create: 2021/06/28 10:13
 */
@Slf4j(topic = "c.ClientTest")
public class ClientTest {

    public static void main(String[] args) throws IOException {
        InetAddress localHost = InetAddress.getLocalHost();
        Socket socket = new Socket(localHost, 9999);
        log.debug("连接服务器成功...");

        OutputStream outputStream = socket.getOutputStream();
        outputStream.write("Hi, Server! I am Client.".getBytes());

        log.debug("通信完成...");
        outputStream.close();
        socket.close();
    }

}
